package top.hjcwzx.wrench.limiter.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.ArrayList;
import java.util.List;

//ip列表配置
@ConfigurationProperties(prefix = "wrench-kit.limiter.ip-list", ignoreInvalidFields = true)
public class RateLimiterIpListAutoProperties {

    /**
     * 白名单
     */
    private List<String> whiteList = new ArrayList<>();

    /**
     * 黑名单
     */
    private List<String> blackList = new ArrayList<>();

    public List<String> getWhiteList() {
        return whiteList;
    }

    public void setWhiteList(List<String> whiteList) {
        this.whiteList = whiteList;
    }

    public List<String> getBlackList() {
        return blackList;
    }

    public void setBlackList(List<String> blackList) {
        this.blackList = blackList;
    }

    /**
     * IP是否在白名单
     */
    public boolean inWhiteList(String ip){
        return whiteList.contains(ip);
    }



    /**
     * IP是否在黑名单
     */
    public boolean inBlackList(String ip){
        return blackList.contains(ip);
    }





}
